/*  header-comment
/*  file   : /Users/arida/react-hrm-h5/src/actions/identify/index
/*  author : arida
/*  date   : 2017-6-4 18:27:41
/*  last   : 2017-8-2 11:35:34
*/
import { createAction } from "redux-actions";
import fetch from "../../utils/fetch.js";
import { get } from "../../utils/db";

export const getUser = createAction("IDENTIFY_GET_USER");

export const fetchUser = query => dispatch => {
  const url = get("isLwp")
    ? "/r/Adaptor/HrmEmployeeInfoVerifyI/"
    : get("baseUrl");
  return fetch(`${url}certyfiIdCard`, {
    body: query,
    meta: {
      dipId: 63669
    }
  }).then(res => {
    if (res.success) {
      dispatch(getUser(res.result));
    }
    return res;
  });
};

export const saveUser = user => () =>
  fetch(`${get("baseUrl")}saveCertyfiIdInfo`, {
    body: user,
    meta: {
      dipId: 63670
    }
  });

export const getFileKey = file => () =>
  fetch(`${get("baseUrl")}uploadImage`, {
    body: file,
    meta: {
      dipId: 63659
    }
  });
